Inheritance

What other object-oriented languages call objects are defined in Ada9X by means of tagged types. A tagged type is a record with a special component, called the tag, which governs dispatching. Tagged types can be extended with additional components. The notion of type extension, as well as the concept of inheritance of operations, are generalisations of the Ada83 mechanism of type derivation. GNAT implements tagged types by following closely the implementation of regular records. The expander transforms tagged types into records according to the following schema:

<#2763#>
verbatim133#
<#2763#>
<#2764#>
verbatim134#
<#2764#>
Extensions are transformed as follows:
<#2765#>
verbatim135#
<#2765#>
<#2766#>
verbatim136#
<#2766#>

The components <#505#>_parent<#505#> and <#506#>_tag<#506#> use ``<#507#>_<#507#>'' as prefix to avoid potential name conflicts with user-defined components. After this transformation, any reference to an inherited component is turned into a reference to the embedded <#508#>_parent<#508#>.